//
//  WelcomeController.swift
//  BQWB
//
//  Created by laibingqiang on 16/10/26.
//  Copyright © 2016年 laibingqiang. All rights reserved.
//

import UIKit
import SDWebImage
class WelcomeController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupUI()
    }
    
    override func loadView() {
        
        view = backImg
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        UIView.animate(withDuration: 1.0, delay: 1.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
            
            self.imgV.snp_updateConstraints(closure: { (make) in
                
                make.top.equalTo(self.view).offset(100)
            })
            
            self.view.layoutIfNeeded()

            
            }) { (_) in
                
                UIView.animate(withDuration: 0.25, animations: {
                    
                    self.messageL.alpha = 1.0
                    
                    }, completion: { (_) in
                        
                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "通知"), object: "童子")
                })

                
        }
//        UIView.animate(withDuration: 2.0, delay: 2.0, options: [], animations: {
//            
//            self.imgV.snp_updateConstraints(closure: { (make) in
//                
//                make.top.equalTo(self.view).offset(100)
//            })
//            
//            self.imgV.layoutIfNeeded()
//            
//            }) { (_) in
//                
//               UIView.animate(withDuration: 0.25, animations: { 
//                
//                self.messageL.alpha = 1.0
//                
//                }, completion: { (_) in
//                    
//                   NotificationCenter.default.post(name: NSNotification.Name(rawValue: "通知"), object: "童子")
//               })
//        }
    }
    func setupUI(){
        
        view.addSubview(imgV)
        view.addSubview(messageL)
        imgV.snp_makeConstraints { (make) in
            
            
            make.size.equalTo(CGSize(width: 90, height: 90))
            make.centerX.equalTo(view)
            make.top.equalTo(view).offset(400)
        }
        messageL.snp_makeConstraints { (make) in
            
            make.centerX.equalTo(view)
            
            make.top.equalTo(imgV.snp_bottom).offset(16)
        }
        
        
        
    }
    private lazy var imgV:UIImageView = {
        
        let img = UIImageView()
        
        img.layer.borderColor = BQTHEMECOLOR.cgColor
        
        img.layer.borderWidth = 1
        
        img.layer.cornerRadius = 45
        
        img.layer.masksToBounds = true
        
        let url = URL(string: (BQOAuthViewModel.shared.accountModel?.avatar_large)!)
        
        
        img.sd_setImage(with: url, placeholderImage: UIImage(named: "avatar_default_big"))
        
        
        return img
    }()
    
    private lazy var backImg:UIImageView = UIImageView(imgName: "ad_background")
    
    private lazy var messageL:UILabel = {
        
        let l = UILabel(text:"hehe" , textColor: BQTHEMECOLOR, fontSize: BQNormalFontSize)
        
        l.textAlignment = .center
        l.alpha = 0.0
        
        return l
    }()
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
